<!DOCTYPE html>
<html lang="zh">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Flask博客</title>
    <link
      href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css"
      rel="stylesheet"
    />
  </head>
  <body>
    <header class="bg-light py-3 mb-4">
      <div class="container">
        <div class="d-flex justify-content-between align-items-center">
          <h1>
            <a
              href="{{ url_for('home') }}"
              class="text-decoration-none text-dark"
              >Flask博客</a
            >
          </h1>
          <nav>
            <ul class="nav">
              <li class="nav-item">
                <a href="{{ url_for('home') }}" class="nav-link">首页</a>
              </li>
              {% if current_user.is_authenticated %}
              <li class="nav-item">
                <a href="{{ url_for('new_post') }}" class="nav-link"
                  >发布文章</a
                >
              </li>
              <li class="nav-item">
                <a
                  href="{{ url_for('user_posts', username=current_user.username) }}"
                  class="nav-link"
                  >我的文章</a
                >
              </li>
              <li class="nav-item">
                <a href="{{ url_for('logout') }}" class="nav-link">退出登录</a>
              </li>
              {% else %}
              <li class="nav-item">
                <a href="{{ url_for('login') }}" class="nav-link">登录</a>
              </li>
              <li class="nav-item">
                <a href="{{ url_for('register') }}" class="nav-link">注册</a>
              </li>
              {% endif %}
            </ul>
          </nav>
        </div>
      </div>
    </header>

    <main class="container mb-5">
      {% with messages = get_flashed_messages() %} {% if messages %} {% for
      message in messages %}
      <div class="alert alert-info">{{ message }}</div>
      {% endfor %} {% endif %} {% endwith %} {% block content %}{% endblock %}
    </main>

    <footer class="bg-light py-3 mt-5">
      <div class="container text-center">
        <p>&copy; {{ now.year }} Flask博客系统</p>
      </div>
    </footer>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
  </body>
</html>
